﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IMark.DAO
{
    public class CauHinhWebsiteModels
    {
        public static CAU_HINH_WEBSITE GetFirst()
        {
            using (var context = new EMartEntities())
            {
                return context.CAU_HINH_WEBSITE.FirstOrDefault();
            }
        }
        public static bool Edit(CAU_HINH_WEBSITE cauHinhWebsite)
        {
            using (var context = new EMartEntities())
            {
                try
                {
                    var existing = context.CAU_HINH_WEBSITE.First();                    
                    existing.EmailLienHe = cauHinhWebsite.EmailLienHe;
                    existing.DiaChiCongTy = cauHinhWebsite.DiaChiCongTy;
                    existing.DienThoaiLienHe = cauHinhWebsite.DienThoaiLienHe;                    
                    existing.Footer = cauHinhWebsite.Footer;                                        
                    existing.LinkFaceBook = cauHinhWebsite.LinkFaceBook;
                    existing.LinkFlickr = cauHinhWebsite.LinkFlickr;
                    existing.LinkGooglePlus = cauHinhWebsite.LinkGooglePlus;
                    existing.LinkTwitter = cauHinhWebsite.LinkTwitter;
                    existing.Logo = cauHinhWebsite.Logo;
                    existing.PhanTrangAdmin = cauHinhWebsite.PhanTrangAdmin;                    
                    existing.SmtpMail = cauHinhWebsite.SmtpMail;
                    existing.SmtpPass = cauHinhWebsite.SmtpPass;
                    existing.SmtpGMail = cauHinhWebsite.SmtpGMail;
                    existing.SmtpPassGMail = cauHinhWebsite.SmtpPassGMail;
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }


    }
}